package marker.xml.metadata;

import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementList;

public class IfInfo {
	@Attribute
	private String value;
	@Attribute
	private String operation;
	@ElementList(name = "cprop", required = false, type = Property.class)
	private List<Property> properties;

	private Property property;

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public Property getProperty() {
		return property;
	}

	public void setProperty(Property property) {
		this.property = property;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public List<Property> getProperties() {
		return properties;
	}

	public void setProperties(List<Property> properties) {
		this.properties = properties;
	}

	

	private String getJavaOperatorString() {
		if (property.getType().equalsIgnoreCase("string")) {
			return ".equals(" + value + ")";
		}
		if (property.getType().equalsIgnoreCase("boolean")) {
			return "==" + value;
		}
		return getAsOperatorString();
	}

	private String getAsOperatorString() {
		if (operation.equals("等于")) {
			return "==" + value;
		}
		if (operation.equals("大于等于")) {
			return ">=" + value;
		}
		if (operation.equals("小于等于")) {
			return "<=" + value;
		}
		if (operation.equals("大于")) {
			return ">" + value;
		}
		if (operation.equals("小于")) {
			return "<" + value;
		}
		if(operation.equals("不等于")){
			return "!="+value;
		}
		throw new RuntimeException(" illegal operator ! ");
 
	}
}
